package com.shwread.android.ui.dialog;

import android.app.ActionBar.LayoutParams;
import android.app.Activity;
import android.app.Dialog;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.Button;

import com.shwread.android.qysw.activity.AddressInfoEditActivity;
import com.shwread.android.qysw10000204.R;

import logic.constants.DefaultConsts;


public class OMSetAddressDialog
        extends
        Dialog
{
	private Context context;
	private Button  ok, cancel;
	
	public OMSetAddressDialog(Context context) {
		super(context, R.style.common_dialog);
		this.context = context;
	}
	
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setCanceledOnTouchOutside(true);
		initView();
		getWindow().setLayout(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
		getWindow().setGravity(Gravity.CENTER);
		getWindow().setWindowAnimations(android.R.style.Animation_InputMethod);
	}
	
	private void initView() {
		View view = LayoutInflater.from(context).inflate(R.layout.om_index_set_address_dialog, null);
		ok = (Button) view.findViewById(R.id.btn_om_index_set_address_sure);
		cancel = (Button) view.findViewById(R.id.btn_om_index_set_address_cancel);
		setContentView(view);
		ok.setOnClickListener(new View.OnClickListener()
		{
			
			@Override
			public void onClick(View v) {
				Intent addressInfoEditIntent = new Intent(context, AddressInfoEditActivity.class);
				addressInfoEditIntent.putExtra(DefaultConsts.EDIT_ADDRESS_FROM_TYPE, DefaultConsts.EDIT_ADDRESS_ADD_TAG);
				((Activity) context).startActivity(addressInfoEditIntent);
			}
		});
		cancel.setOnClickListener(new View.OnClickListener()
		{
			
			@Override
			public void onClick(View v) {
				dismiss();
			}
		});
	}
	
}
